﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq.Expressions;
using SL8.SL.Extensions;

namespace SL8.SL.Controls
{
    public class SearchConditionCollectPanel : PanelBase, System.ComponentModel.INotifyPropertyChanged
    {
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        public System.Type EntityType
        {
            get
            {
                return (Type)base.GetValue(SearchConditionCollectPanel.EntityTypeProperty);
            }

            set
            {
                base.SetValue(SearchConditionCollectPanel.EntityTypeProperty, value);
            }
        }

        public LambdaExpression SearchConditionLambda
        {
            get
            {
                return this.GetSearchExpressionByEntityType(this.EntityType);
            }
        }

        public static readonly DependencyProperty EntityTypeProperty = DependencyProperty.Register("EntityType",
            typeof(Type),
            typeof(SearchConditionCollectPanel), null);

        public SearchConditionCollectPanel()
        {
            this.DefaultStyleKey = typeof(SearchConditionCollectPanel);
        }

        internal void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }

        public void RaiseSearchConditionLambdaPropertyChanged()
        {
            this.RaisePropertyChanged("SearchConditionLambda");
        }
    }
}
